package com.wing.purchase.model.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 采购请购单
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("pur_purchase_requisitions")
public class PurchaseRequisitions extends BaseEntity<PurchaseRequisitions> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {

        /**
         * 待确认
         */
        stayConfirm(0, "待确认"),
        /**
         * 待审核
         */
        stayAudit(1, "待审核"),
        /**
         * 审核成功
         */
        success(2, "审核成功"),
        /**
         * 审核拒绝
         */
        fail(3, "审核拒绝"),
        /**
         * 已关闭
         */
        closed(4, "已关闭");

        private int code;
        private String desc;

        Status(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        public String getDesc() {
            return this.desc;
        }
    }

    public enum EnquiryStatus implements IEnum<Integer> {

        /**
         * 待生成询价单
         */
        stayGenerateInquiry(0, "待生成订单"),
        /**
         * 询价中
         */
        inquiry(1, "询价中"),

        /**
         *
         */
        purchase(2, "采购中"),

        /**
         * 询价结束
         */
        finish(3, "结束");

        private int code;
        private String desc;

        EnquiryStatus(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        public String getDesc() {
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 单据号
     */
    private String receiptsNo;

    /**
     * 采购单核对ID
     */
    private Long purchasePlanCheckId;

    /**
     * 确认人
     */
    private Long affirmant;

    /**
     * 审核人
     */
    private Long auditor;

    /**
     * 关闭人
     */
    private Long shutter;

    /**
     * 状态
     */
    private Status status;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 审核失败原因
     */
    private String reason;

    /**
     * 询价状态
     */
    private EnquiryStatus enquiryStatus;

    /**
     * 询价状态描述
     */
    @TableField(exist = false)
    private String enquiryStatusDesc;

    public String getEnquiryStatusDesc() {
        return enquiryStatus == null ? null : enquiryStatus.getDesc();
    }

    /**
     * 采购请购单明细集合
     */
    @TableField(exist = false)
    private List<PurchaseRequisitionsDetail> purchaseRequisitionsDetails = new ArrayList<>();

    /**
     * 部门ID
     */
    private Long departmentId;

    /**
     * 部门名称
     */
    @TableField(exist = false)
    private String departmentName;

    /**
     * 1.简易采购流程  2.基本采购流程
     */
    private String generatorType;

}
